﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Pahan.McuFusion.FusionBoot
{
    internal static class ControlSumUtils
    {
        public static byte ControlSum(this IEnumerable<byte> data)
        {
            return data.ControlSum(0);
        }
        
        public static byte ControlSum(this IEnumerable<byte> data, byte initial)
        {
            return data.Aggregate(initial, (sum, item) => (byte)(sum ^ item));
        }
    }
}
